<html>
<head>
	<%@ page pageEncoding="utf-8"%>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<title>广联云</title>
	<meta name="description" content="">
	<meta name="author" content="">
	<meta name="viewport" content="width=device-width">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/js/libs/bootstrap/css/bootstrap.css"/>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/libs/jquery/jquery.js"></script>
</head>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<body style="margin: 20px">
<h2>Rest API Test Page</h2>
<h3>Token: <%= request.getSession().getAttribute("oauth_token") %></h3>
		<input type="hidden" id="apisystem" value="<%=request.getAttribute("apisystem") %>">
		<input type="hidden" id="apitype" value="<%=request.getAttribute("apitype") %>">
		<input type="hidden" id="baseURI" value="<%=request.getAttribute("baseURI") %>">
	<form action="system" id="systemform">
		<br>
		Please Select System
		<br>
		<select style="width: 100px" name="apisystem" onchange="changesystem();">
			<option id="account" value="account">account</option>
			<option id="document" value="document">document</option>
			<option id="file" value="file">file</option>
			<option id="recycler" value="recycler">recycler</option>
			<option id="share" value="share">share</option>
			<option id="job" value="job">job</option>
			<option id="QTO" value="QTO">QTO</option>
			<option id="activity" value="activity">activity</option>
		</select>
		<select style="width: 100px" name="apitype" onchange="changesystem();">
				<option id="external" value="external">external</option>
				<option id="internal" value="internal">internal</option>
			</select>
	</form>
	<%= request.getAttribute("apiinfo") %>
	<form id="test">
		<%= request.getAttribute("baseURI") %><input id="path" type="text" name="path" style="width: 800px;height: 30px" >
			<select style="width: 100px" id="methodType">
				<option value="get">get</option>
				<option value="post">post</option>
				<option value="put">put</option>
				<option value="delete">delete</option>
			</select>
			
	    <input value="submit" type="submit"/>
			<br>
		<textarea rows="2" cols="10" id="body" style="width: 800px"></textarea>
	</form>
	<div id="data" >
		${data }
	</div>
</body>
</html>
<script type="text/javascript">
	function changesystem(){
		$("#systemform").submit();
	}
	function test(){
//		alert($("#methodType").val());
	}
	$(function(){
		$("#test").submit(function(){
			$.ajax({
				url : "test.json" ,
				data: {path:$("#path").val(),
					methodType:$("#methodType").val(),
					body:$("#body").val(),
					baseURI:$("#baseURI").val(),
					apitype:$("#apitype").val(),
					apisystem:$("#apisystem").val()
				},
				type: "post",
				success : function( data,a,b){
					$("#data").html( data.data )
				}
			});
			return false;
		});
		var apisystem = $("#apisystem").val();
		$("#"+apisystem).attr("selected", "selected");
		var apitype = $("#apitype").val();
		$("#"+apitype).attr("selected", "selected");
	}
	)

</script>
